<?php

//if (isset($_COOKIE['name'])) {
//    $name1 = $_COOKIE['name'];
//} else {
//    $name1 = '';
//    exit('不允许操作');
//}
session_start();
if (isset($_SESSION['name'])) {
    $name1 = $_SESSION['name'];
} else {
    $name1 = '';
    exit('不允许操作');
}

define('HOST', 'localhost');
define('USER', 'mes');
define('PASSWORD', '111111');
define('DATABASE', 'mes');
$id = $_REQUEST['id'];
$name=$_REQUEST['name'];
$content=$_REQUEST['mes'];
$conn = mysqli_connect(HOST, USER, PASSWORD, DATABASE)or die('数据库连接失败' . mysqli_connect_error());
$sql = "delete from liuyan where id=$id and username='$name1'";
$res = mysqli_query($conn, $sql);
if (mysqli_affected_rows($conn) != 1) {
    echo '<script>alert("删除失败！");window.location="liuyan0.php"</script>';
} else {
    echo '<script>alert("删除成功！");window.location="liuyan0.php"</script>';
}